﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;

namespace Medianamik.Core.ImportExport
{
    public class JsonNodeTypeDataSourceDataSerializer : NodeTypeDataSourceDataSerializer
    {
        public override void Serialize(IEnumerable<RecordType> recordTypes, System.IO.TextWriter writer)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            //serializer.RegisterConverters(new JavaScriptConverter[] { new RecordConverter() });
            writer.Write(serializer.Serialize(recordTypes));
        }

        public override NodeTypeDataSourceData Deserialize(string jSon)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            //serializer.RegisterConverters(new JavaScriptConverter[] { new RecordConverter() });
            return serializer.Deserialize<NodeTypeDataSourceData>(jSon);
        }
    }
}
